numRows = 5
var generate = function (numRows) {
    let res = new Array(numRows).fill(1).map((item, index) => {
        return new Array(index + 1).fill(1)
    })
    for (let i = 2; i < res.length; i++) {
        for (let j = 1; j < i; j++) {
            res[i][j] = res[i - 1][j - 1] + res[i - 1][j]
        }
    }
    return res;
}
console.log(generate(numRows));

